package com.example.videomedian;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class VideoAdapter extends BaseAdapter {
    private Context context;
    private List<MediaBean>list;

    public VideoAdapter(Context context, List<MediaBean> list) {
        super();
        this.list=list;
        this.context=context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int i) {
        return 0L;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        view= LayoutInflater.from(context).inflate(R.layout.video_item,null);

        ImageView img=view.findViewById(R.id.imageView);
        TextView tv=view.findViewById(R.id.videoName);
        TextView time=view.findViewById(R.id.videoTime);

        MediaBean bean=list.get(position);


        time.setText("上次看到："+bean.lastTime);


        img.setImageBitmap(bean.getvImg());
        tv.setText(bean.vName);

        return view;
    }
}
